
import { Component, OnInit } from '@angular/core';
import {PersonalProgectInformation} from "../entity/PersonalProgectInformation";
import {UserService} from "../service/user.service";
import {Router, Params} from "@angular/router";
import {ActivatedRoute} from "@angular/router";
import {Page} from "../../shared/entity/Page";
@Component({
  selector: 'personal-follow',
  templateUrl: './personal-follow.html',

})
export class personalFollowComponent implements OnInit {
  public personalfollowMessage:Array<PersonalProgectInformation>;
  public page:Page<PersonalProgectInformation> = new Page<PersonalProgectInformation>();
  private currentUserId:string;
  constructor(
    private activatedRouter: ActivatedRoute,
    private userservice:UserService,public router:Router) { }

  public toProjectIndex(id:string){
    this.router.navigate(['/project/index/',id]);
  }

  ngOnInit() {
    this.activatedRouter.params
    // (+) converts string 'id' to a number
      .switchMap((params: Params) =>
        this.userservice.getPersonalFollowMessage(this.currentUserId=params["id"],params["pageNo"]))
      .subscribe((page: Page<PersonalProgectInformation>)=>{
         this.page = page;
      });
  }
  public setPage(pageNo:string){
    this.router.navigate(['/personal/personalFollow/',{id:this.currentUserId+"", pageNo: pageNo}]);
  }

}
